/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.bopet.jocadv.core.datum;

import eu.bopet.jocadv.core.Element;
import eu.bopet.jocadv.core.Optimizable;
import java.io.Serializable;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

/**
 * The class represent coordinate systems in three dimensional space
 *
 * @author bocskapeter
 */
public class CSys extends Element implements Serializable, Optimizable {

    // origin of the coordinate system
    private Vector3D origin;
    // x axis
    private Vector3D axisX;
    // y axis
    private Vector3D axisY;
    //z axis
    private Vector3D axisZ;

    /**
     * Builds a new coordinate system on the given point
     *
     * @param origin as Vector3D
     * @return new CSys coordinate system
     */
    public static CSys getDefaultCSys(Vector3D origin) {
        CSys cs = new CSys("CS");
        cs.setOrigin(origin);

        cs.setAxisX(Vector3D.PLUS_I);
        cs.setAxisY(Vector3D.PLUS_J);
        cs.setAxisZ(Vector3D.PLUS_K);

        return cs;
    }

    /**
     * Default constructor
     *
     * @param name
     */
    public CSys(String name) {
        super(name);
    }

    /**
     * Gets the origin
     *
     * @return origin as Vector3D
     */
    public Vector3D getOrigin() {
        return origin;
    }

    /**
     * Sets the origin
     *
     * @param origin as Vector3D
     */
    public void setOrigin(Vector3D origin) {
        this.origin = origin;
    }

    /**
     * Gets x axis
     *
     * @return x axis as Vector3D
     */
    public Vector3D getAxisX() {
        return axisX;
    }

    /**
     * Sets x axis
     *
     * @param axisX as Vector3D
     */
    public void setAxisX(Vector3D axisX) {
        this.axisX = axisX;
    }

    /**
     * Gets y axis
     *
     * @return y axis as Vector3D
     */
    public Vector3D getAxisY() {
        return axisY;
    }

    /**
     * Sets y axis
     *
     * @param axisY as Vector3D
     */
    public void setAxisY(Vector3D axisY) {
        this.axisY = axisY;
    }

    /**
     * Gets z axis
     *
     * @return z axis as Vector3D
     */
    public Vector3D getAxisZ() {
        return axisZ;
    }

    /**
     * Sets z axis
     *
     * @param axisZ as Vector3D
     */
    public void setAxisZ(Vector3D axisZ) {
        this.axisZ = axisZ;
    }

    /**
     * Converts to String
     *
     * @return Sting
     */
    @Override
    public String toString() {
        return "\n CSys{" + super.toString() + "origin=" + origin + ", axisX=" + axisX + ", axisY=" + axisY + ", axisZ=" + axisZ + '}';
    }

    /**
     * Gives the point (variables) of the equation
     *
     * @return array of double values
     */
    @Override
    public double[] getVaraiables() {
        return new double[]{this.origin.getX(), this.origin.getY(), this.origin.getZ(),this.axisX.getX(),this.axisX.getY(),this.axisX.getZ(),this.axisY.getX(),this.axisY.getY(),this.axisY.getZ(),this.axisX.getZ(),this.axisZ.getY(),this.axisZ.getZ()};
    }

}
